<?php
namespace app\api\controller;
use app\model\OpAccount;
use app\model\Token;
use app\model\Recharge;
use app\model\ItemConsume;
class Qq {

    function funds_get($access_token='c0f91150e1a8ed6f34d01b0c73bc9510') 
    {
        // $interface = 'funds/get';
        $interface = 'wechat_funds/get';
        $url = 'https://api.e.qq.com/v1.1/' . $interface;
        
        $common_parameters = array (
            'access_token' => $access_token,
            'timestamp' => time(),
            'nonce' => md5(uniqid('', true))
        );
        
        // $parameters = array (
        //     'trade_type' => 'AGENCY_REFUND_FROM_ADVERTISER',
        //     // 'filtering' => [
        //     //     'field' => '18922474',
        //     //     'operator' => 'EQUALS ',
        //     //     // 'values' => '广告'
        //     // ],
        //     'date_range' => [
        //         'start_date' => '2021-02-21',
        //         'end_date' => '2021-02-21'
        //     ]
        // );
        $parameters = array (
            'account_id' => '18922474',
            
        );
        // $parameters = array (
        //     'page' => 1,
        //     'page_size' => 10,
        // );

        $parameters = array_merge($common_parameters, $parameters);
        
        foreach ($parameters as $key => $value) {
            if (!is_string($value)) {
                $parameters[$key] = json_encode($value);
            }
        }
        
        $request_url = $url . '?' . http_build_query($parameters);
        dump($request_url);
        $headers = [
            'Content-Type:application/json',
        ];
        
        $rs = json_decode(http_get($request_url,$headers),true);
        dump($rs);
        // $curl = curl_init();
        // curl_setopt($curl, CURLOPT_URL, $request_url);
        // curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
        // curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        // $response = curl_exec($curl);
        // if (curl_error($curl)) {
        //     $error_msg = curl_error($curl);
        //     $error_no = curl_errno($curl);
        //     curl_close($curl);
        //     throw new \Exception($error_msg, $error_no);
        // }
        // curl_close($curl);
       
        // return $response;
    }
















}